Search SDK: Fixing DateTime deserialization and time zone-specific un…#1378
Merged
ogail merged 1 commit intoAzure:masterfrom Aug 19, 2015
Merged
Search SDK: Fixing DateTime deserialization and time zone-specific un…#1378ogail merged 1 commit intoAzure:masterfrom
ogail merged 1 commit intoAzure:masterfrom
Conversation
…it tests NOTE: I am not incrementing the NuGet package version because there is another PR coming very soon and there's no point in shipping a new SDK version that will only live for one day. Apparently deserialization of DateTime in Search results has been broken since the Search SDK first shipped (DateTimeOffset deserialization works fine). The root cause is the "double deserialization" we need to do in order to "unflatten" the search response JSON. First we deserialize to JObject and capture the OData annotations (for things like @search.highlight, @search.score, etc.). This results in the DateTime fields being deserialized into DateTimeOffsets. Next, we deserialize again into the user's model class, which was resulting in an InvalidCastException because JSON.NET can't cast DateTimeOffset to DateTime. The fix is to add some read logic to DateTimeConverter (and a lot of new test coverage). I also took the opportunity to fix some unit tests that weren't running correctly in other time zones. This bug was reported back in June: Azure#1202
|
Hi @brjohnstmsft, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!
TTYL, AZPRBOT; |
ogail
added a commit
that referenced
this pull request
Aug 19, 2015
Search SDK: Fixing DateTime deserialization and time zone-specific un…
brjohnstmsft
added a commit
to brjohnstmsft/azure-sdk-for-net
that referenced
this pull request
Aug 21, 2015
Used git cherry-pick to move these recent PRs from the master branch to the AutoRest branch: Azure#1384 Azure#1378
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…it tests
NOTE: I am not incrementing the NuGet package version because there is
another PR coming very soon and there's no point in shipping a new SDK
version that will only live for one day.
Apparently deserialization of DateTime in Search results has been broken
since the Search SDK first shipped (DateTimeOffset deserialization works
fine). The root cause is the "double deserialization" we need to do in order
to "unflatten" the search response JSON. First we deserialize to JObject and
capture the OData annotations (for things like @search.highlight,
@search.score, etc.). This results in the DateTime fields being deserialized
into DateTimeOffsets. Next, we deserialize again into the user's model class,
which was resulting in an InvalidCastException because JSON.NET can't cast
DateTimeOffset to DateTime. The fix is to add some read logic to
DateTimeConverter (and a lot of new test coverage).
I also took the opportunity to fix some unit tests that weren't running
correctly in other time zones. This bug was reported back in June:
#1202